package com.airticketbooking.mapper;

import com.airticketbooking.common.domain.PageQuery;
import com.airticketbooking.po.User;
import com.airticketbooking.vo.UserPageVO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * @author Mr.J
 * @version 1.0.0
 * @Date 2024/11/11
 * @desc
 */

@Mapper
public interface UserMapper {

	@Select("SELECT * FROM airticketbooking.user WHERE user_name = #{userName}")
	User getUserByUserName(String userName);

	@Insert("insert into airticketbooking.user(user_name, Email, phone_number, password,create_date,update_date,status)" +
			" values(#{userName},#{email},#{phoneNumber},#{password},#{createDate},#{updateDate},#{status}) ")
	void add(User user);


	void update(User user);

	@Select("SELECT * FROM airticketbooking.user WHERE user_id = #{userId}")
	User getUserById(Integer userId);


	Page<UserPageVO> getUserByPage(PageQuery pageQuery);

	@Select("SELECT COUNT(*) FROM airticketbooking.user")
	Integer getAllUsers();

	Integer getUsersNumInRangeTime(Date startTime, Date endTime);

	@Select("SELECT * FROM airticketbooking.user")
	List<User> getAll();
}
	